package com.yuelan.codelib.utils;

public class MathUtil {

	// 对double类型的数字进行精确并且四舍五入 precision为精确到多少位

	public static Double roundDouble(double val, int precision) {
		Double ret = null;
		try {
			double factor = Math.pow(10, precision);
			ret = Math.floor(val * factor + 0.5) / factor;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ret;
	}

	public static boolean getWin(int value) {
		int[] array = new int[100];
		for (int i = 0; i < array.length; i++) {
			if (i < value) {
				array[i] = 1;
			} else {
				array[i] = 0;
			}
		}
		int getv = (int) (Math.random() * 100);
		if (array[getv] == 1) {
			return true;
		}
		return false;
	}
}
